<?php
$sqlquery = <<< EOT
DROP TABLE IF EXISTS `prefix_order`;
CREATE TABLE `prefix_order` (
`orderid`  int(11) UNSIGNED NOT NULL AUTO_INCREMENT ,
`userid`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '购买者userid' ,
`username`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '购买者姓名' ,
`ordid`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0' COMMENT '订单号' ,
`ordtime`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '订单时间' ,
`productid`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '产品id' ,
`ordtitle`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '订单标题' ,
`ordbuynum`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '购买数量' ,
`ordprice`  float(10,2) UNSIGNED NOT NULL DEFAULT 0.00 COMMENT '产品单价' ,
`ordfee`  float(10,2) UNSIGNED NOT NULL DEFAULT 0.00 COMMENT '订单总金额' ,
`ordstatus`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '订单状态  ‘0’为交易未支付 ‘1’为交易成功 ‘2’为交易取消' ,
`payment_type`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '支付类型' ,
`payment_trade_no`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '支付接口交易号' ,
`payment_trade_status`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '支付接口返回的交易状态' ,
`payment_notify_id`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' ,
`payment_notify_time`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' ,
`payment_buyer_email`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' ,
`ordcode`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' ,
`isused`  int(11) UNSIGNED NOT NULL DEFAULT 0 ,
`usetime`  int(11) UNSIGNED NOT NULL DEFAULT 0 ,
`checkuser`  int(11) UNSIGNED NOT NULL DEFAULT 0 ,
`payment`  varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '支付宝' COMMENT '支付方式' ,
`email`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '邮箱' ,
`telephone`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '联系电话' ,
`usernote`  varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '备注' ,
`discount`  float(3,2) NOT NULL DEFAULT 0.00 COMMENT '打折' ,
`point`  int(100) UNSIGNED NOT NULL DEFAULT 0 COMMENT '点数' ,
PRIMARY KEY (`orderid`)
)TYPE=MyISAM;

DROP TABLE IF EXISTS `prefix_pay_spend`;
CREATE TABLE `prefix_pay_spend` (
`id`  int(10) UNSIGNED NOT NULL AUTO_INCREMENT ,
`creat_at`  int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间' ,
`userid`  int(10) UNSIGNED NOT NULL DEFAULT 0 ,
`username`  varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`type`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '消费类型' ,
`logo`  varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`value`  int(5) UNSIGNED NOT NULL ,
`op_userid`  int(10) UNSIGNED NOT NULL DEFAULT 0 ,
`op_username`  char(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '操作人' ,
`msg`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '消费内容 ' ,
PRIMARY KEY (`id`),
INDEX `type` (`type`) USING BTREE ,
INDEX `creat_at` (`creat_at`) USING BTREE ,
INDEX `logo` (`logo`) USING BTREE ,
INDEX `userid` (`userid`) USING BTREE 
)TYPE=MyISAM;

DROP TABLE IF EXISTS `prefix_payment`;
CREATE TABLE `prefix_payment` (
`pay_id`  tinyint(3) UNSIGNED NOT NULL AUTO_INCREMENT ,
`name`  varchar(120) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`pay_name`  varchar(120) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`pay_code`  varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`pay_desc`  text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`pay_method`  tinyint(1) NULL DEFAULT NULL ,
`pay_fee`  varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`config`  text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`is_cod`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 ,
`is_online`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 ,
`pay_order`  tinyint(3) UNSIGNED NOT NULL DEFAULT 0 ,
`enabled`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 ,
`author`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`website`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`version`  varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
PRIMARY KEY (`pay_id`),
INDEX `pay_code` (`pay_code`) USING BTREE 
)
TYPE=MyISAM;

INSERT INTO `prefix_payment` VALUES ('4', '支付宝', '支付宝', 'Alipay', '支付宝是国内领先的独立第三方支付平台，由阿里巴巴集团创办。致力于为中国电子商务提供&ldquo;简单、安全、快速&rdquo;的在线支付解决方案。', '0', '0', 'array (\n  \'alipay_account\' => \n  array (\n    \'name\' => \'支付宝帐户\',\n    \'type\' => \'text\',\n    \'value\' => \'xianlin85@163.com\',\n  ),\n  \'alipay_key\' => \n  array (\n    \'name\' => \'交易安全校验码(key)\',\n    \'type\' => \'text\',\n    \'value\' => \'rj4v72nz0io3dnrjgvnfxs39ixj7obqx\',\n  ),\n  \'alipay_partner\' => \n  array (\n    \'name\' => \'合作者身份(parterID)\',\n    \'type\' => \'text\',\n    \'value\' => \'2088002076412897\',\n  ),\n  \'service_type\' => \n  array (\n    \'name\' => \'选择接口类型\',\n    \'type\' => \'select\',\n    \'value\' => \'2\',\n    \'range\' => \n    array (\n      0 =>  \'使用即时到账交易接口\',\n    ),\n  ),\n)', '0', '1', '0', '1', 'PHPCMS开发团队', 'http://www.alipay.com', '1.0.0');

EOT;
$menuid = D('Node')->add(array('parentid'=>72,'name'=>'在线充值','m'=>'Pay','c'=>'Pay','a'=>'pay_list'));
D('Node')->add(array('parentid'=>$menuid,'name'=>'支付模块','m'=>'Pay','c'=>'Pay','a'=>'init'));
D('Node')->add(array('parentid'=>$menuid,'name'=>'充值记录','m'=>'Pay','c'=>'Pay','a'=>'pay_list'));
D('Node')->add(array('parentid'=>$menuid,'name'=>'充值入账','m'=>'Pay','c'=>'Pay','a'=>'modify_deposit'));
D('Node')->add(array('parentid'=>$menuid,'name'=>'消费记录','m'=>'Pay','c'=>'Spend','a'=>'init'));
?>